{% extends "PATHomeBundle::base.html.twig" %}
{% block title %}{{ parent() }} Détail de l'article{% endblock %}
{% block body %}
<div id="boutique">
    <div id="boutique_left">
        {% if product.picture.url is defined %}
        <img src = "{{ asset('bundles/patproduct/images/' ~ product.picture.url) }}" alt = {{ product.picture.title }} />
        {% else %}
        <img src = "{{ asset('bundles/patproduct/images/non_dispo.png') }}" alt="image non disponible"/>
        {% endif %}
    </div>

    <div id="boutique_center">
            <h1>{{ product.name }}</h1>
            
            <fieldset>
                <legend>Détails du produit</legend>
                <p>{{ product.descriptionLong }}</p>
            </fieldset> 
    </div>
    <div id="boutique_right">
        <div class="boxCheckout">
            <div id="ratings_container">
                <div id="ratings_border"></div>
		<div id="ratings_title">
                    <div>L'AVIS DE NOS CLIENTS</div>
		</div>
		<div id="ratings_notification">
                    {{ product.getAverageRate()|striptags('<div>')|raw }}
                </div>
            </div>
            <div class="boxPrice">
                <div class="overflowPrice">
                    {% if product.stock.id == 1 %}
                    <span class="en_stock">{{ product.stock.status }}</span>
                    {% elseif product.stock.id == 2 %}
                    <span class="en_appro">{{ product.stock.status }}</span>
                    {% elseif product.stock.id == 3 %}
                    <span class="non_dispo">{{ product.stock.status }}</span>
                    {% endif %}
                    <br/>
                    <br/>
                    <span>Prix</span>
                    <span class="price_nowrap">{{ product.priceHT }} €</span>
                </div>
            </div>
            <div class="buttonBox" id="cartButtonBox">
                <a href="{{ path('pat_cart_add', { 'productId':product.id }) }}">Ajouter au panier</a>
            </div>
            <div class="linkBox">
                {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
                    <a href="javascript:void()" 
                       onclick="document.getElementById('dialog_choose_wishlist').style.display='block';
                                document.getElementById('fade').style.display='block'"
                    >
                        <div class="addToWishList"><img src="../../pictures/design/hearthAlone.png" /></div>
                    </a>
                {% else %}
                    <div class="addToWishList"><img src="../../pictures/design/hearthAlone.png" /></div>
                {% endif %}
                    <div class="recommendToBuddy"><img src="../../pictures/design/recommendToBuddy.png" /></div>
            </div>      
        </div>
            <img src="../../pictures/design/info_paiement.jpg" alt="info paiement" width="210px"/>
    </div>
</div>
<div id="comments_container">
    <h2>Avis des utilisateurs ({{ product.comments|length }})</h2>
        <input type="button" value="Donnez votre avis" class="generic_link" onclick="document.getElementById('dialog_add_comment').style.display='block';document.getElementById('fade').style.display='block'"/>
        <div id="comments_list">
        {% if product.comments|length > 0 %}
        {% for comment in product.comments %}
        <div class="comment">
            <table class="comments_table">
                <tr>
                    <td colspan=2>
                        Publié le {{ comment.pubDate|date('d/m/Y') }} par {{ comment.user.username }}.
                    </td>
                </tr>
                <tr>
                    <td class="td_rating" rowspan=2>
                        {{ comment.getRateHtml()|striptags('<div>')|raw }}
                    </td>
                    <td>
                        <h3>{{ comment.title }}</h3>
                    </td>
                </tr>
                <tr>
                    <td>
                        {{ comment.text }}
                    </td>
                </tr>
            </table>
        </div>
        {% endfor %}
        {% else %}
        <center>Aucun commentaire pour cet article.</center>
        {% endif %}
    </div>
</div>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
<div id="dialog_choose_wishlist">
    <table>
        {% for wishlist in user.wishlists %}
        <tr>
            <td>{{ wishlist.name }}</td>
            <td>
                <a href="{{ path('pat_product_chooseWishlist', { 'productId': product.id, 'wishlistId': wishlist.id }) }}">
                    <img src="{{ asset('bundles/patwishlist/images/icone-pos.png') }}" alt="Add"/>
                </a>
            </td>
        </tr>
        {% endfor %}
    </table>
    <input type="button" value="Annuler" class="generic-link" onclick = "document.getElementById('dialog_choose_wishlist').style.display='none';document.getElementById('fade').style.display='none'"/>
</div>
<div id="dialog_add_comment">
    <form method="post" {{ form_enctype(addForm) }}>
        <fieldset>
            {{ form_widget(addForm) }}
        </fieldset>
            <input class="generic_link" type="submit" class="btn btn-primary" />
            <input type="button" value="Annuler" onclick = "document.getElementById('dialog_add_comment').style.display='none';document.getElementById('fade').style.display='none'"/>
        </form>
</div>
<div id="fade" class="black_overlay">
</div>
{% endif %}
{% endblock %}